import request from "@/utils/request";

// 注册接口
export const userRegisterService = ({
  username,
  password,
  captchaKey,
  captcha,
}) =>
  request.post("/api/reg", {
    username,
    password,
    captchaKey,
    captcha,
  });

// 登录接口
export const userLoginService = ({ username, password, captchaKey, captcha }) =>
  request.post("/api/login", { username, password, captchaKey, captcha });

// 获取用户基本信息
export const userGetInfoService = () => request.get("/user/userinfo");

// 更新用户基本信息
export const userUpdateInfoService = ({ id, nickname, email }) =>
  request.put("/user/userinfo", { id, nickname, email });

// 更新用户头像
export const userUpdateAvatarService = (formData) =>
  request.patch("/user/update/avatar", formData, {
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });

// 更新用户密码
export const userUpdatePasswordService = ({ old_pwd, new_pwd, re_pwd }) =>
  request.patch("/user/updatepwd", { old_pwd, new_pwd, re_pwd });
